﻿using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace GestionSaludOcupacional.Portal
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            Optimization();
        }

        private void Optimization()
        {
            /*Base script*/
            var bundleBase = new ScriptBundle("~/Scripts/base");
            bundleBase.Include("~/Scripts/bootstrap.js");
            bundleBase.Include("~/Scripts/knockout-2.1.0.js");
            bundleBase.Include("~/Scripts/knockout.mapping-latest.js");
            bundleBase.Include("~/Scripts/thrid-party/sammyjs/sammy-latest.min.js");
            bundleBase.Include("~/Scripts/views/shared/utils.js");

            /*Base css*/
            var bundleCssBase = new StyleBundle("~/Content/base");
            bundleCssBase.Include("~/Content/bootstrap.css");
            bundleCssBase.Include("~/Content/stylebase.css");
            bundleCssBase.Include("~/Content/bootstrap-responsive.css");
            /*Css*/
            BundleTable.EnableOptimizations = true;
            BundleTable.Bundles.Add(bundleCssBase);
            BundleTable.Bundles.Add(bundleBase);
        }
    }
}